package com.msmall.community.question.preparer;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.preparer.ViewPreparer;

import com.msmall.base.cache.CacheFactory;
import com.msmall.base.util.Constants;
import com.msmall.community.common.model.Commend;

public class QuestionMotherPreparer implements ViewPreparer{
	private static final Log log = LogFactory.getLog(QuestionMotherPreparer.class);
	
	@SuppressWarnings("unchecked")
	public void execute(TilesRequestContext tilesContext, AttributeContext context) {
		try{
			HttpServletRequest request = (HttpServletRequest) tilesContext.getRequest();
			List<Commend> commends = (List<Commend>) CacheFactory.getInstance().getCache(Constants.CACHE_NAME_COMMON).get(Constants.CACHE_KEY_QUESTION_COMMEND_MOTHER);
			request.setAttribute("questionIndexMother", commends);
		}catch(Exception e){
			log.debug(e);
		}
	}
}
